<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/banner/appBanner.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>运营商</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>编辑APP轮播图</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });

</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">编辑APP轮播图</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frmBanner">
                        <input id="bannerId" name="bannerId" value="${tenantBanner.bannerId}" type="hidden">
                        <div class="form-group row">

                            <label class="col-sm-3 col-form-label text-right">类型：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="imgType" id="imgType">
                                    <option value="0"
                                            <c:if test="${tenantBanner.imgType eq '0'}">selected</c:if> >APP启动广告图
                                    </option>
                                    <option value="1"
                                            <c:if test="${tenantBanner.imgType eq '1'}">selected</c:if> >APP首页轮播图
                                    </option>
                                    <option value="2"
                                            <c:if test="${tenantBanner.imgType eq '2'}">selected</c:if> >APP充电中广告图
                                    </option>
                                    <option value="3"
                                            <c:if test="${tenantBanner.imgType eq '3'}">selected</c:if> >APP首页弹框广告图
                                    </option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">点击跳转路径：</label>
                            <div class="col-sm-8">
                                <input type="url" class="form-control" id="accessUrl" name="accessUrl"
                                       value="${tenantBanner.accessUrl}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">使用状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="status" id="status">
                                    <option value="0"
                                            <c:if test="${tenantBanner.status eq '0'}">selected</c:if>   >停用
                                    </option>
                                    <option value="1"
                                            <c:if test="${tenantBanner.status eq '1'}">selected</c:if>  >使用
                                    </option>
                                </select>
                            </div>
                        </div>
                        <c:choose>
                            <c:when test="${tenantBanner.imgType eq '0'}">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label text-right">图片：</label>
                                    <div class="col-sm-8">
                                        <div id="">
                                            <c:choose>
                                                <c:when test="${tenantBanner.appStartImg!=null && tenantBanner.appStartImg!=''}">
                                                    <div id="">
                                                        <img id="appStartImg"
                                                             src="${uploadPath}${tenantBanner.appStartImg}"
                                                             width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:when>
                                                <c:otherwise>
                                                    <div id="">
                                                        <img id="appIndexImg" src="${ctx}/statics/img/upload-img.png"
                                                             style="position: relative" width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                        <span>图片尺寸建议为：<span class="text-danger">98px*75px</span></span>
                                    </div>
                                </div>
                            </c:when>
                        </c:choose>
                        <c:choose>
                            <c:when test="${tenantBanner.imgType eq '1'}">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label text-right">图片：</label>
                                    <div class="col-sm-8">
                                        <div id="">
                                            <c:choose>
                                                <c:when test="${tenantBanner.appIndexImg!=null && tenantBanner.appIndexImg!=''}">
                                                    <div id="">
                                                        <img id="appIndexImg"
                                                             src="${uploadPath}${tenantBanner.appIndexImg}"
                                                             width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:when>
                                                <c:otherwise>
                                                    <div id="">
                                                        <img id="appIndexImg" src="${ctx}/statics/img/upload-img.png"
                                                             style="position: relative" width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                        <span>图片尺寸建议为：<span class="text-danger">98px*75px</span></span>
                                    </div>
                                </div>
                            </c:when>
                        </c:choose>
                        <c:choose>
                            <c:when test="${tenantBanner.imgType eq '2'}">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label text-right">图片：</label>
                                    <div class="col-sm-8">
                                        <div id="">
                                            <c:choose>
                                                <c:when test="${tenantBanner.appFlashImg!=null && tenantBanner.appFlashImg!=''}">
                                                    <div id="">
                                                        <img id="appFlashImg"
                                                             src="${uploadPath}${tenantBanner.appFlashImg}"
                                                             width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:when>
                                                <c:otherwise>
                                                    <div id="">
                                                        <img id="appFlashImg" src="${ctx}/statics/img/upload-img.png"
                                                             style="position: relative" width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                        <span>图片尺寸建议为：<span class="text-danger">98px*75px</span></span>
                                    </div>
                                </div>
                            </c:when>
                        </c:choose>
                        <c:choose>
                            <c:when test="${tenantBanner.imgType eq '3'}">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label text-right">图片：</label>
                                    <div class="col-sm-8">
                                        <div id="">
                                            <c:choose>
                                                <c:when test="${tenantBanner.appFlashAdImg!=null && tenantBanner.appFlashAdImg!=''}">
                                                    <div id="">
                                                        <img id="appFlashAdImg"
                                                             src="${uploadPath}${tenantBanner.appFlashAdImg}"
                                                             width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:when>
                                                <c:otherwise>
                                                    <div id="">
                                                        <img id="appFlashAdImg" src="${ctx}/statics/img/upload-img.png"
                                                             style="position: relative" width="155px" height="120px">
                                                        <input type="file" id="file" name="file"/>
                                                    </div>
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                        <span>图片尺寸建议为：<span class="text-danger">98px*75px</span></span>
                                    </div>
                                </div>
                            </c:when>
                        </c:choose>
                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    $("#file").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#appIndexImg").attr("src", objUrl);
        }
    });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

    addAppBanner.init();
</script>
</body>
</html>
